package com.chang.demo.controller;

import com.chang.demo.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.HashMap;

@RestController
@Api(value = "测试实体类", tags = {"测试钱钱钱"})
@RequestMapping(path = "/demo")
public class TestController {


    @RequestMapping(path = "/test", method = RequestMethod.POST)
    @ApiOperation(value = "测试接口", tags = "测试")
    public HashMap<String, Object> test (@RequestBody User user) {
        Class<User> userClass = User.class;
        Field[] declaredFields = userClass.getDeclaredFields();
        System.out.println(declaredFields);
        Annotation[] declaredAnnotations = userClass.getDeclaredAnnotations();
        System.out.println(declaredAnnotations);
        System.out.println(userClass);
        HashMap<String, Object> result = new HashMap<>();
        result.put("code", "200");
        result.put("data", user);
        result.put("message", "成功");
        return result;
    }

    @RequestMapping(path = "/requestUser", method = RequestMethod.POST)
    @ApiOperation(value = "用户测试", notes = "用户测试说明")
    public User testUser (@RequestBody User user) {
        return new User();
    }
}
